package com.gaussian.property.app.controller;

import com.gaussian.property.module.biz.entity.AppUser;
import com.gaussian.property.module.biz.service.IAppUserService;
import com.songqi.common.core.domain.R;
import com.songqi.common.security.model.LoginUser;
import com.songqi.common.security.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2024/4/19 11:24
 */
@Api(tags = "账号相关")
@RestController
@Validated
@RequestMapping("account/")
public class AccountController {

    @Resource
    private IAppUserService iAppUserService;

    @Resource
    private TokenService tokenService;
    /**
     * 获取用户信息
     *
     * @return 用户信息
     */
    @ApiOperation("根据token查询用户信息")
    @GetMapping("getInfo")
    public R<AppUser> getInfo(HttpServletRequest request)
    {
        LoginUser loginUser = tokenService.getLoginUser(request);
        AppUser appUser = iAppUserService.getById(loginUser.getUsername());
        return R.success(appUser);
    }
}
